package f;

import java.io.File;

public class DirOp extends FileOp implements Op {

	@Override
	public int add(File old) {
		int ret = -1;
		if(old.isDirectory()) {
			int r = -1;
			File[] ff = old.listFiles();
			for(File f: ff) {
				r = super.add(f);
				if(r!=-1) {
					ret += r;
				}
			}
		}else if(old.isFile()) {
			ret = super.add(old);
		}
		return ret;
	}

	@Override
	public int delete(File jm) {
		return super.delete(jm);
	}

	@Override
	public boolean backOne(File jmf, File to) {
		if(jmf.isDirectory() && to.isDirectory()) {
			File[] ff = jmf.listFiles();
			for(File f: ff) {				
				super.backOne(f, to);
			}
		}
		return false;
	}

}
